package com.pucong.gitee.database.backup.business.unRelational.redis.controller;

import com.pucong.gitee.database.backup.business.unRelational.redis.service.AutoRedisService;
import com.pucong.gitee.database.backup.common.entity.redis.dto.RedisCmdDto;
import com.pucong.gitee.database.backup.utils.Res;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/auto/redis/connect")
public class ConnectController {

    @Autowired
    private AutoRedisService autoRedisService;

    @GetMapping("/isopenConnect/{id}")
    @ApiOperation(value = "检测连接状态")
    public Res<Boolean> isopenConnect(@ApiParam("主键") @PathVariable("id") String id) {
        Boolean aBoolean = autoRedisService.isopenConnect(id);
        return Res.ok(aBoolean);
    }

    @PostMapping("/cmdwinConnect/{id}")
    @ApiOperation(value = "cmd执行连接")
    public Res<String> cmdwinConnect(@ApiParam("主键") @PathVariable("id") String id,@RequestBody RedisCmdDto dto) {
        String s = autoRedisService.cmdwinConnect(id, dto.getCmd());
        return Res.ok(s);
    }

}
